package org.west.sky.frame.activiti.study.chapter18;

import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.west.sky.frame.activiti.study.util.ActivitiEngineUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * author: chz
 * date: 2025/6/6
 * description: 事件监听器
 */
public class RunDemo18_2_5 extends ActivitiEngineUtil {

    public static void main(String[] args) {
        RunDemo18_2_5 runDemo18_1_1 = new RunDemo18_2_5();
        runDemo18_1_1.run();
    }

    public void run() {
        // 启动流程
        loadActivitiConfigAndInitEngine();
        ProcessDefinition processDefinition = deployByClassPathResource("processes/chapter18/Chapter18_2_5.bpmn20.xml");

        ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
        System.out.println("====流程实例ID：" + processInstance.getId());

        Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
        System.out.println("====第一个任务id:" + task.getId() + ",任务名称：" + task.getName());
        taskService.complete(task.getId());

        closeEngine();
    }
}
